package com.wude.guild.dialog;

import android.app.Dialog;
import android.content.ClipboardManager;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.mc.developmentkit.utils.ToastUtil;
import com.wude.guild.R;

import org.xutils.x;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 领取礼包的Dialog
 * Created by Administrator on 2017/3/15.
 */

public class GiftDialog extends Dialog {

    @BindView(R.id.close)
    ImageView close;
    @BindView(R.id.jihuoma)
    TextView jihuoma;
    @BindView(R.id.fuzhi)
    TextView fuzhi;
    private View inflate;
    private String jihuo;

    public GiftDialog(Context context, int themeResId) {
        super(context, themeResId);
        inflate = LinearLayout.inflate(context, R.layout.dialog_gift, null);
    }

    public GiftDialog(Context context) {
        super(context);
    }

    protected GiftDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            //  getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        }
        setContentView(inflate);
        ButterKnife.bind(this);
        jihuoma.setText(jihuo);
    }

    public GiftDialog setTitle(String s) {
        jihuo = s;
        return this;
    }

    @OnClick({R.id.close, R.id.fuzhi})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.close:
                dismiss();
                break;
            case R.id.fuzhi:
                ClipboardManager cmb = (ClipboardManager) x.app().getSystemService(Context.CLIPBOARD_SERVICE);
                cmb.setText(jihuo);
                ToastUtil.showToast("复制完成");
                break;
        }
    }
}
